﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExcelRefresh.Processing
{
    public class ProcessingQueue<T>
        where T : class, IComparable<T>
    {
        #region Nested Types

        //[System.Diagnostics.DebuggerDisplay("{Item}")]
        //private class ProcessableItem<T> : IProcessable<T> where T : class, IComparable<T>
        //{
        //    public ProcessableItem(T item, Action<T> processor)
        //    {
        //        Item = item;
        //        Processor = processor;
        //        Status = ProcessingStatus.Queued;

        //        System.Threading.Tasks.TaskScheduler.Current.MaximumConcurrencyLevel = 4;

        //    }

        //    public override string ToString()
        //    {
        //        return Item.ToString();
        //    }

        //    private readonly Action<IProcessable<T>> _processor;
        //    private readonly T _item;
        //    private readonly int _maxProcessingAttempts;
        //    private ProcessingStatus _status;
            
        //    public T Item { get { return _item; } }
        //    public ProcessingStatus Status { get { return _status; } }
        //    public int MaxProcessingAttempts  { get { return _maxProcessingAttempts; } }

        //    private LinkedList<IProcessingAttempt<T>> _attempts;
        //    public IEnumerable<IProcessingAttempt<T>> Attempts { get { return _attempts ?? Enumerable.Empty<IProcessingAttempt<T>>();} }

        //    public void Process()
        //    {
        //    }

        //}
        
        #endregion
        
        
        //private readonly List<ProcessableItem<T>> _items;

        //public void Enqueue(T item, Action<T> processor)
        //{
        //    lock (_items)
        //    {
        //        var processor = _items.FirstOrDefault(p => p.Item == item);
        //        if (processor == null)
        //        {
        //            processor = new ProcessableItem<T>(item, action);
        //            _items.Add(processor);
        //        }

        //    }
        //}
    }


}
